package com.example.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.metrics.CounterService;
import org.springframework.boot.actuate.metrics.GaugeService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Service
public class MetricsService {
    @Autowired
    private CounterService counterService;

    @Autowired
    private GaugeService gaugeService;

    @Scheduled(fixedDelay = 1000)
    public void exampleMethod() {
        this.counterService.increment("test.add");
        gaugeService.submit("test.gauge", 20.1);
    }

}